﻿using System;
using System.Data;
using AjaxPro;
using WorkFlow.DBProxy;
using WorkFlow.Desinger.Code;

namespace WorkFlow.Desinger.newDesinger
{
    [AjaxNamespace("ns")]
    public partial class WFDesinger : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Utility.RegisterTypeForAjax(GetType(),Page);
        }

        [AjaxMethod]
        public DataTable GetModules()
        {
            return
                DB.MapToDataTable(@"select f_id as MID,F_NAME AS MNAME ,f_url as FILES from t_modules ORDER BY F_NAME");
        }

        [AjaxMethod]
        public bool SaveWf(string[] arr, string html,string xml)
        {
            return new ProcessInWf().PraserProcess(arr, html.Trim(),xml.Trim(), GetUserId);
        }

        private int GetUserId
        {
            get
            {
                return Convert.ToInt32("12");
            }
        }

        
        /// <summary>
        /// 根据流程id获取xml信息
        /// </summary>
        /// <param name="processId"></param>
        /// <returns></returns>
        [AjaxMethod]
        public  string GetXml(string processId)
        {
            return ProcessInWf.GetXml(processId);
        }

        /// <summary>
        /// 根据流程id获取html信息
        /// </summary>
        /// <param name="processId"></param>
        /// <returns></returns>
        [AjaxMethod]
        public  string GetHtml(string processId)
        {
            return ProcessInWf.GetHtml(processId);
        }

        
    }
}